﻿@{
    ViewBag.Title = "WristPrint";
}
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <meta http-equiv="Cache" content="no-cache" />
    <title>急性胸痛患者腕带打印</title>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/common.js?v=@DateTime.Now.ToString("yyyyMMdd")"></script>
    <script src="~/Scripts/CreateControl.js?v=@DateTime.Now.ToString("yyyyMMdd")" type="text/javascript"></script>
    <style type="text/css">
        html {  overflow-x: hidden; overflow-y: hidden; }
    </style>
</head>
<body style="height:400px;">
    <script type="text/javascript">
        CreatePrintViewerEx("100%", "80%", '@Url.Content("~/Grf/胸痛.grf")' + '?id=' + getRnd(), "", true, "<param name=BorderStyle value=1>");
        $(document).ready(function () {
            PrintStart();
        });
        function PrintStart() {
            var pid = "@ViewBag.pid";
            $.ajax({
                url: "/ChestPainCenter/MedicalRecords/GetCaseHistory?Pid=" + pid,
                cache: false,
                success: function (data) {
                    var d = $.parseJSON(data);
                    if (d.Result == 1) {
                        var jsonData = $.parseJSON(d.Body);
                        ReportViewer.Stop();
                        var Report = ReportViewer.Report;
                        var Recordset = ReportViewer.Report.DetailGrid.Recordset;
                        var PATIENT_ID = ReportViewer.Report.FieldByName("PATIENT_ID");
                        var PATIENT_NAME = ReportViewer.Report.FieldByName("PATIENT_NAME");
                        var PATIENT_SEX = ReportViewer.Report.FieldByName("PATIENT_SEX");
                        var PATIENT_AGE = ReportViewer.Report.FieldByName("PATIENT_AGE");

                        Report.PrepareLoadData();
                        Recordset.Append();
                        PATIENT_ID.AsString = jsonData.PatientId == null ? "" : jsonData.PatientId;
                        var PatCardNO = jsonData.PatCardNO;
                        if (typeof (PatCardNO) != "undefined" && PatCardNO != null && PatCardNO != "" && PatCardNO.toString().length > 0) {
                            var spatcardno = PatCardNO.substring(0, 1);
                            var num_reg = /^\d+$/;
                            if (num_reg.test(spatcardno)) {
                                PATIENT_ID.AsString = PatCardNO;
                            }
                        }
                        PATIENT_NAME.AsString = jsonData.PatientName == null ? "" : jsonData.PatientName;
                        PATIENT_SEX.AsString = jsonData.PatientSex == null ? "" : jsonData.PatientSex;
                        PATIENT_AGE.AsString = jsonData.PatientAge == null ? "" : jsonData.PatientAge;

                        Recordset.Post();
                        ReportViewer.Start();
                    }
                }
            });
        }
        function GetConsciousness(ids) {
            if (typeof (ids) == "undefined" || ids == null || ids.length <= 0) return "";
            var idArray = ids.split(',');
            var res = "";
            for (var i = 0; i < idArray.length; i++) {
                switch (parseInt(idArray[i])) {
                    case 1:
                        res += "清醒/";
                        break;
                    case 2:
                        res += "对语言有反应/";
                        break;
                    case 3:
                        res += "对刺痛有反应/";
                        break;
                    case 4:
                        res += "对任何刺激无反应/";
                        break;
                    default:
                        break;
                }
            }
            if (res.length > 0)
                res = res.substring(0, res.length - 1);
            return res;
        }
        function GetArriveClassName(id) {
            if (typeof (id) == "undefined" || id == null || id.length <= 0) return "";
            switch (parseInt(id)) {
                case 0:
                    return "未知";
                case 1:
                    return "120";
                case 2:
                    return "转院";
                case 3:
                    return "自行来院";
                case 4:
                    return "院内发病";
                default:
                    return "未知";
            }
        }
    </script>
</body>
</html>